package com.yulinlin.admin.modules.aspectj;


import com.yulinlin.common.util.AopUtil;
import com.yulinlin.common.util.RequestUtil;
import com.yulinlin.data.core.util.JsonUtil;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.concurrent.ThreadPoolExecutor;

@Component
@Aspect

public class AjaxLogAspectj {



    @Autowired
    ThreadPoolExecutor threadPoolExecutor;

    @Pointcut("@annotation(com.yulinlin.common.anno.AjaxLog)" +
            "|| @within(com.yulinlin.common.anno.AjaxLog)"
    )
    public void aop() {

    }

    @Around("aop()")
    public Object doAroundAdvice(ProceedingJoinPoint pjp) throws Throwable{

        String url = RequestUtil.getUrl();

        String className =  pjp.getTarget().getClass().getSimpleName();

        String methodName =  pjp.getSignature().getName();


        Map args = AopUtil.getParams(pjp);
        String json =  JsonUtil.toJson(args);



        long x = System.currentTimeMillis();

        Object  value = pjp.proceed();
        long y = System.currentTimeMillis();
        long runTime = y -x;

     /*   threadPoolExecutor.submit(() -> {


        });*/

        return  value;



    }
}
